public class Solution36 {
    public boolean isValidSudoku(char[][] board) {
        int[][] rows = new int[9][9], columns = new int[9][9], subBoxes = new int[9][9];
        for (int i = 0; i < 9; i++) {
            for (int j = 0; j < 9; j++) {
                if (board[i][j] != '.') {
                    int num = board[i][j] - '1';
                    rows[i][num]++;
                    columns[j][num]++;
                    int index = (i / 3) * 3 + j / 3;
                    subBoxes[index][num]++;
                    if (rows[i][num] > 1 || columns[j][num] > 1 || subBoxes[index][num] > 1) {
                        return false;
                    }
                }
            }
        }
        return true;
    }
}
